﻿


$(document).ready(function () {
    setInterval(function () { myTimer() }, 1000);

});

function reduceMessagesNumber() {
	try{
		
		var i = 0;
		var len = $('.history > div').length;
		var bottomMargin=$(".chatArea").offset().top+$(".chatArea").height()-$('.history > div.message:last').offset().top+40;
		$('.mainSenior .history > div').each(function () {
			if ( i != len - 1 && ($(window).height()-$('.history > div.message:last').offset().top<bottomMargin)) {
				$(this).hide();
			} 
			i++;
		});
		$(window).trigger("resize"); //this fixes fittext plugin
	} catch(err) {
	
	}
}

function currentTime()
{
    var d = new Date();
    var seconds = d.getSeconds();
    seconds < 10 ? seconds = '0' + seconds : seconds;
    var minutes = d.getMinutes();
    minutes < 10 ? minutes = '0' + minutes : minutes;
    var hours = d.getHours();
    hours < 10 ? hours = '0' + hours : hours;
    var t = hours + ":" + minutes + ":" + seconds;
    return t;
}

function myTimer() {

    var t = currentTime()
	$('.clock').html(t);
}


var myApp = angular.module('PubNubChat', []).directive('coolFade', function () {
    return {
        compile: function (elm) {
            //console.log('compiling');
            $(elm).css('opacity', 0);
            return function (scope, elm, attrs) {
                // console.log('animating');
                $(elm).animate({
                    opacity: 1.0
                }, 1000);
            };
        }
    };
});


//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

